$(function () {
    var backFn = function () {
        $.showPage("", "系统用户", webRoot + "/console/systemUsers/index.html");
    };

    // 返回按钮
    $("#back").on("click", function () {
        backFn();
    });

    var statusArr = [{"id": 0, "name": "禁用"}, {"id": 1, "name": "启用"}];

    $('#status').combobox({
        id: "status",
        data: statusArr
    });

    var option = {
        dataType: 'json',
        beforeSubmit: function(formData, $form, option) {
            $form.disableSubmitButton(true);
        },
        success: function () {
            Notify('添加成功', 'bottom-right', '5000', 'success', 'fa-check', true);
            setTimeout(backFn, 1000);
        },
        error: function (response, status, error, $form) {
            Notify(response.responseJSON.message, 'bottom-right', '5000', 'danger', 'fa-bolt', true);
            $form.disableSubmitButton(false);
        }
    };

    $("form").ajaxForm(option);
});